package EinkauferActionListener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

import javax.swing.JComboBox;
import javax.swing.JTable;

import Einkaufer.KonfigurationTable;

public class ComboBoxListener implements ActionListener {

	String selectedItem;
	KonfigurationTable kt;
	JTable tableKonfiguration;
	
	public ComboBoxListener(KonfigurationTable kt, JTable tableKonfiguration) {
		this.kt = kt;
		this.tableKonfiguration = tableKonfiguration;
	}

	@Override
	public void actionPerformed(ActionEvent e) {


		JComboBox cb = (JComboBox)e.getSource();
        selectedItem = cb.getSelectedItem().toString();
        
        try {
			kt.initKonfigurationTable(this.selectedItem);
		} catch (SQLException ed) {
			// TODO Auto-generated catch block
			ed.printStackTrace();
		}
		tableKonfiguration.setModel(kt.getKtm());

	}

	

}
